package org.insightech.er.test;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.insightech.er.ERDiagramActivator;
import org.insightech.er.db.impl.mysql.MySQLDBManager;
import org.insightech.er.db.sqltype.SqlType;
import org.insightech.er.editor.model.ERDiagram;
import org.insightech.er.editor.model.diagram_contents.element.node.table.ERTable;
import org.insightech.er.editor.model.diagram_contents.element.node.table.column.NormalColumn;
import org.insightech.er.editor.model.diagram_contents.not_element.dictionary.TypeData;
import org.insightech.er.editor.model.diagram_contents.not_element.dictionary.Word;
import org.insightech.er.editor.model.testdata.TestData;
import org.insightech.er.editor.view.dialog.testdata.detail.TestDataDialog;

public class TestDataEditTest {

    private final Display display = new Display();
    private final Shell shell = new Shell(display);

    public static void main(final String[] args) throws Exception {
        new ERDiagramActivator();
        new TestDataEditTest();
    }

    public TestDataEditTest() {
        initialize(shell);
    }

    private void initialize(final Composite parent) {
        final ERDiagram diagram = new ERDiagram(MySQLDBManager.ID);
        final ERTable table = new ERTable();
        table.setPhysicalName("table1");
        table.setLogicalName("table1");
        final TypeData typeData = new TypeData(null, null, false, null, false, false, false, null, false);

        final Word word1 = new Word("a", "a", SqlType.valueOfId("bigint"), typeData, null, MySQLDBManager.ID);

        final NormalColumn column1 = new NormalColumn(word1, true, true, true, true, null, null, null, null, null);

        final Word word2 = new Word("a", "a", SqlType.valueOfId("bigint"), typeData, null, MySQLDBManager.ID);
        final NormalColumn column2 = new NormalColumn(word2, true, true, true, true, null, null, null, null, null);
        table.addColumn(column1);
        table.addColumn(column2);

        diagram.addContent(table);

        final TestDataDialog dialog = new TestDataDialog(shell, diagram, new TestData());

        dialog.open();
    }
}
